Skip to content

fix: tool_choice 指定 web_search 等服务端工具时开启对应的 Google 工具 - #214

Merged
Mag1cFall merged 1 commit into
mainfrom
fix/hosted-tool-choice
Nov 22, 2026
Merged

Mag1cFall merged 1 commit into
mainfrom
fix/hosted-tool-choice

Conversation

@Mag1cFall

Copy link
Copy Markdown
Owner

Fixes #212

  • 修了什么:Claude Code 内置的 WebSearch 以 tool_choice: {"type":"tool","name":"web_search"} 指定 web_search_20250305 时,服务返回 400 “tool choice references undeclared function "web_search"”。
  • 原因:named tool 的 tool_choice 一律按客户端函数处理,web_search 是 server tool,转成 Google 搜索后不在函数声明中,于是被当作未声明的函数拒绝。
  • 怎么修的:tool_choice 指定 web_search、web_fetch、code_execution 等 server tool 时,本次只开启对应的 Google 工具并要求模型使用它,不再放进允许调用的函数名单。

@Mag1cFall
Mag1cFall merged commit 886e0c0 into main Nov 22, 2026
4 checks passed
@Mag1cFall
Mag1cFall deleted the fix/hosted-tool-choice branch November 22, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Claude Code WebSearch returns HTTP 400 when Anthropic tool_choice forces web_search

1 participant